package com.sky.member.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sky.common.annotation.Log;
import com.sky.common.core.controller.BaseController;
import com.sky.common.core.domain.AjaxResult;
import com.sky.common.enums.BusinessType;
import com.sky.member.domain.TbCrewMember;
import com.sky.member.service.ITbCrewMemberService;
import com.sky.common.utils.poi.ExcelUtil;
import com.sky.common.core.page.TableDataInfo;

/**
 * 剧组人员管理Controller
 * 
 * @author ruoyi
 * @date 2025-11-08
 */
@RestController
@RequestMapping("/member/member")
public class TbCrewMemberController extends BaseController
{
    @Autowired
    private ITbCrewMemberService tbCrewMemberService;

    /**
     * 查询剧组人员管理列表
     */
    @PreAuthorize("@ss.hasPermi('member:member:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbCrewMember tbCrewMember)
    {
        startPage();
        List<TbCrewMember> list = tbCrewMemberService.selectTbCrewMemberList(tbCrewMember);
        return getDataTable(list);
    }

    /**
     * 导出剧组人员管理列表
     */
    @PreAuthorize("@ss.hasPermi('member:member:export')")
    @Log(title = "剧组人员管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbCrewMember tbCrewMember)
    {
        List<TbCrewMember> list = tbCrewMemberService.selectTbCrewMemberList(tbCrewMember);
        ExcelUtil<TbCrewMember> util = new ExcelUtil<TbCrewMember>(TbCrewMember.class);
        util.exportExcel(response, list, "剧组人员管理数据");
    }

    /**
     * 获取剧组人员管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('member:member:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tbCrewMemberService.selectTbCrewMemberById(id));
    }

    /**
     * 新增剧组人员管理
     */
    @PreAuthorize("@ss.hasPermi('member:member:add')")
    @Log(title = "剧组人员管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbCrewMember tbCrewMember)
    {
        return toAjax(tbCrewMemberService.insertTbCrewMember(tbCrewMember));
    }

    /**
     * 修改剧组人员管理
     */
    @PreAuthorize("@ss.hasPermi('member:member:edit')")
    @Log(title = "剧组人员管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbCrewMember tbCrewMember)
    {
        return toAjax(tbCrewMemberService.updateTbCrewMember(tbCrewMember));
    }

    /**
     * 删除剧组人员管理
     */
    @PreAuthorize("@ss.hasPermi('member:member:remove')")
    @Log(title = "剧组人员管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbCrewMemberService.deleteTbCrewMemberByIds(ids));
    }
}
